import sys
reload(sys)
sys.setdefaultencoding('utf8')

INCPATH = ['.'
    , '..'
    , '../../include']
SRCPATH = ['./'
    , '../'
    , '../../']
LIBRARY = ['pthread', 'rt', 'dl', 'c']

SRC = []
for path in SRCPATH :
    SRC.append(Glob(path + '*.c'))
    SRC.append(Glob(path + '*.cpp'))

env = Environment()

mode = ARGUMENTS.get('mode', 'debug')
if mode == 'debug':
    env['CCFLAGS'] = ['-g']
    env['CXXFLAGS'] = ['-g']
    print 'scons: in debug mode.'
elif mode == 'release':
    env['CCFLAGS'] = []
    env['CXXFLAGS'] = []
    print 'scons: in release mode.'

build = ARGUMENTS.get('build', 'x86')
if build == 'x86':
    env['CC'] = 'gcc'
    env['CXX'] = 'g++'
    print 'scons: build in x86.'
elif build == 'arm':
    env['CC'] = 'gcc'
    env['CXX'] = 'g++'
    print 'scons: build in arm.'

print 'scons: c ' + env['CC']
print 'scons: c++ ' + env['CXX']

# Configuring compilation options
env['CCFLAGS'] += ['-O1']
env['CXXFLAGS'] += ['-O1']

env.Program('main'
    , SRC
    , LIBS = LIBRARY
    , CPPPATH = INCPATH
    , CCCOMSTR="gcc $SOURCES"
    , CXXCOMSTR="g++ $SOURCES"
    , LINKCOMSTR="LINK $TARGET"
    )
